package com.example.springboot.config.schedule;

import com.example.springboot.service.IMetAlarmService;
import com.example.springboot.service.IProductServerService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ScheduledTasks {

    private final IMetAlarmService  metAlarmService;

    private final IProductServerService productServerService;
    @Scheduled(fixedRate = 60000) // 每60秒执行一次
    public void checkAndNotify() {
        // 检查met_alarm表的逻辑
        metAlarmService.checkAndSendAlarms();
        // 如果有符合条件的记录，则发送通知到微信小程序
    }

    @Scheduled(fixedRate = 60000) // 每60秒执行一次
    public void checkAndNotifyProductFile() {
        // 监控product_server表的逻辑
        productServerService.checkAndSendProductMessage();
        // 如果有符合条件的记录，则发送通知到微信小程序
    }
}
